package shop.services;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import shop.dao.CaterageDao;
import shop.pojo.Caterage;
import shop.util.SqlSessionUtil;

public class CaterageService {
	//查询分类
	public List<Caterage> seleAllCaterage(){
		SqlSession se = new SqlSessionUtil().getSqlSession();
		CaterageDao sd = se.getMapper(CaterageDao.class);
		return sd.CaterageSel();
	}
	//查询当前页的分类信息
		public List<Caterage> selePageCaterage(int page){
			SqlSession se = new SqlSessionUtil().getSqlSession();
			CaterageDao sd = se.getMapper(CaterageDao.class);
			return sd.CaterageCurrentPageSel(page);
		}
	//添加分类
	public int insertintoCaterage(Caterage c){
		SqlSession se = new SqlSessionUtil().getSqlSession();
		CaterageDao sd = se.getMapper(CaterageDao.class);
		int i;
		i=sd.CaterageAddss(c);
		se.commit();
		return  i;
	}
	//根据分类id 查询出分类信息
	public Caterage seleOneCaterage(int id){
		SqlSession se = new SqlSessionUtil().getSqlSession();
		CaterageDao sd = se.getMapper(CaterageDao.class);
		return sd.CaterageSelOne(id);
	}
	//修改分类信息
	public int CaterageUpt(Caterage c){
		SqlSession se = new SqlSessionUtil().getSqlSession();
		CaterageDao sd = se.getMapper(CaterageDao.class);
		int i;
		i = sd.CaterageUpt(c);
		se.commit();
		return i;
	}
	//删除分类信息
	public void deleteCaterage(int c_id){
		SqlSession se = new SqlSessionUtil().getSqlSession();
		CaterageDao sd = se.getMapper(CaterageDao.class);
		int i;
		i = sd.Cateragedele(c_id);
		se.commit();
	}
}
